
export default {
	namespaced:true,
	state: {
		userList:[],
		user:{
			userName:'',
			userNumber:'',
			password:'',
			logons:false,
		},
	},
	getters: {
		getUser:(state)=>{
			return state.user;
		},
		getUserList:(state)=>{
			return state.userList;
		}
	},
	mutations: {
		update(state,user){
			console.log(user);
			state.userList.forEach((item)=>{
				if(item.userNumber = user.userNumber){
					item.userName = user.userName;
					item.userNumber = user.userNumber;
					item.password = user.password;
				}
			})
			console.log(state.userList);
		},
		add(state,user){
			state.userList.push(user)
		},
		login(state,user){
			state.user.userName = user.userName;
			state.user.userNumber = user.userNumber;
			state.user.password = user.password;
			state.user.logons = user.logons;
		},
		lognout:(state)=>{
			state.user={
				userName:'',
				userNumber:'',
				password:'',
				logons:false,
			}
		}
	},
	actions: {
		addUser({state,commit},user){
			commit('add',user);
		},
		loginS({state,commit},user){
			commit('login',user);
		},
		logOut({state,commit}){
			commit('lognout');
		},
		updateUser({state,commit},user){
			commit('update',user);
		}
	}
}